﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CostaRicaPureTravelUtils.EmailConfiguration;
using CostaRicaPureTravelUtils;
using System.Net.Mail;

namespace CostaRicaPureTravel.Controller
{
    public class EmailController
    {

        private EmailSection section;

        public EmailController(HttpContext context) {
            section = EmailConfigLoader.getInstance(context).getEmailSection(); 
        }

        public void SendAsync(string address, string displayName, string subject, string body, bool isHTML )
        {
            MailService.SendAsync(address, displayName, section.Address, section.DisplayName, 
                MailPriority.Normal, subject, body, isHTML, section.Host, section.Port,
                section.EnableSSL, section.DefaultCredentials, section.UserName, section.Password);
        }

        public void Send(string address, string displayName, string subject, string body, bool isHTML)
        {
            MailService.Send(address, displayName, section.Address, section.DisplayName, 
                MailPriority.Normal, subject, body, isHTML, section.Host, section.Port,
                section.EnableSSL, section.DefaultCredentials, section.UserName, section.Password);
        }
    }
}